<template>
  <!-- 将主题设置为暗黑模式，绑定到 isDarkMode 变量 -->
  <a-config-provider :locale="locale" :theme="{ dark: true }">
    <router-view />
    <global-setting />
  </a-config-provider>
</template>

<script lang="ts" setup>
  import { computed, ref, onMounted } from 'vue';
  import enUS from '@arco-design/web-vue/es/locale/lang/en-us';
  import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
  import GlobalSetting from '@/components/global-setting/index.vue';
  import useLocale from '@/hooks/locale';

  const { currentLocale } = useLocale();
  const locale = computed(() => {
    switch (currentLocale.value) {
      case 'zh-CN':
        return zhCN;
      case 'en-US':
        return enUS;
      default:
        return enUS;
    }
  });

  // 页面加载时强制设置为暗黑模式
  onMounted(() => {
    // 强制设置暗黑模式，无论系统设置如何
    document.body.setAttribute('arco-theme', 'dark');
  });
</script>
